package com.chixing.util;

import com.chixing.pojo.Praised;
import org.apache.commons.codec.digest.DigestUtils;

public class MD5Utils {
    public static final String SALT = "1a2b3c4d";

    public static String md5(String src){
        return DigestUtils.md5Hex(src);
    }

    public static String inputPassToFormPass(String password){
        String str = ""+SALT.charAt(5) + SALT.charAt(4) + password + SALT.charAt(3) + SALT.charAt(2);
        return md5(str);
    }
    public  static String formPassToDBPass(String password,String salt){
        String str = "" + salt.charAt(0) + salt.charAt(2) + password+ salt.charAt(5) + salt.charAt(4);
        return md5(str);
    }
    public static String inputPassToDBPass(String password,String dbSalt){
        String firstMd5 = inputPassToFormPass(password);
        String seconfMd5 = formPassToDBPass(firstMd5,dbSalt);
        return seconfMd5;
    }
    public static void main(String[] args) {
        String password = "123456";
        String salt = "1a2b3c4d";

        System.out.println(inputPassToDBPass(password, salt));
    }
}
